package com.itheima.method;
/*
        需求：设计一个方法，该方法能够同时获取数组的最大值，和最小值

        注意: return语句, 只能带回一个结果.
*/
public class ImportantTest9 {
    public static void main(String[] args) {

        int[] arr ={11, 22, 33, 44, 55};
        int[] maxAndmin = getMaxAndMin(arr);
        System.out.println("最大值为:" + maxAndmin[0]);
        System.out.println("最小值为:" + maxAndmin[1]);
    }
    public static int[] getMaxAndMin(int[] arr){
        int max = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if(arr[i] > max){
                max = arr[i];
            }
        }
        int min = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if(arr[i] < min){
                min = arr[i];
            }
        }
        int[] maxAndMin ={max, min};
        return maxAndMin;
    }

    public static class Test4 {
        public static void main(String[] args) {
            double max = maxnum(10, 20);
            System.out.println(max);
        }

        public static double maxnum(double a, double b) {
            return a > b ? a : b;
        }
    }
}

